package com.da.ngix.ngix.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @ClassName TestController
 * @Description TODO
 * @Author lyd
 * @Date 2025/2/7 15:24
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private Environment environment;


    @RequestMapping("/hello")
    public String hello(HttpServletRequest request){
        System.out.println("当前端口号是: " + request.getServerPort());
        String property = environment.getProperty("server.port");
        return "当前端口号是: " + property;
    }
}
